package com.lepu.app.fun.chat.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.app.utils.Setting;
import com.core.lib.utils.photo.UniversalImageLoadTool;
import com.core.lib.widget.CircularImageView;
import com.lepu.app.fun.chat.bean.BeanDoctorMy;
import com.lepu.pasm.R;

public class DoctorMyAdapter extends BaseAdapter {

	private LayoutInflater mLayoutInflater = null;
	@SuppressWarnings("unused")
	private Context mContext = null;
	private List<BeanDoctorMy> mArrayList = null;

	public DoctorMyAdapter(Context context, List<BeanDoctorMy> arrayList) {
		mContext = context;
		mLayoutInflater = LayoutInflater.from(context);
		mArrayList = arrayList;
	}

	@Override
	public int getCount() {
		int size = 0;
		if (mArrayList != null && mArrayList.size() > 0) {
			size = mArrayList.size();
		}
		return size;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		final ViewHolder holder;

		if (convertView == null) {
			convertView = mLayoutInflater.inflate(R.layout.chat_doctor_my_listitem, null);

			holder = new ViewHolder();
			
			CircularImageView accountIconImageView = (CircularImageView) convertView.findViewById(R.id.accountIconImageView);
			TextView hospitalNameTextView  = (TextView) convertView.findViewById(R.id.hospitalNameTextView);
			TextView nameTextView  = (TextView) convertView.findViewById(R.id.nameTextView);
			TextView keNameTextView  = (TextView) convertView.findViewById(R.id.keNameTextView);
			TextView stateTextView  = (TextView) convertView.findViewById(R.id.stateTextView);
			
			holder.accountIconImageView = accountIconImageView;
			holder.hospitalNameTextView = hospitalNameTextView;
			holder.nameTextView = nameTextView;
			holder.keNameTextView = keNameTextView;
			holder.stateTextView = stateTextView;

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		BeanDoctorMy item = mArrayList.get(position);
		
		UniversalImageLoadTool.disPlay(Setting.getImageUrl(item.UniqueID),
				holder.accountIconImageView, R.drawable.chat_doctor_icon_default);
		
		holder.hospitalNameTextView.setText(item.HospitalName);
		holder.nameTextView.setText(item.DoctorName);
		holder.keNameTextView.setText(item.DepartmentName);
		
		if(item.Status == 1)
		{
			holder.stateTextView.setVisibility(View.VISIBLE);
			holder.stateTextView.setText("等待验证");
		}else{
			holder.stateTextView.setVisibility(View.GONE);
		}

		return convertView;
	}

	private static class ViewHolder {
		CircularImageView accountIconImageView;
		TextView hospitalNameTextView;
		TextView nameTextView;
		TextView keNameTextView;
		TextView stateTextView;
	}
}
